﻿using SqlSugar;

namespace WechatH5Auth.RazorWebUI.Entity;

/// <summary>
/// 请求记录表
/// 按季度分表
/// </summary>
[SugarTable("RequestLogs_{year}{month}{day}", "请求记录表 按季度分表")]
[SplitTable(SplitType.Season)]
public class RequestLogs
{
	/// <summary>
	/// 雪花Id
	/// </summary>
	[SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true)]
	public long Id { get; set; }

	/// <summary>
	/// AppID
	/// </summary>
	[SugarColumn(ColumnDescription = "AppID", IsNullable = true, Length = 50)]
	public string? AppID { get; set; }

	/// <summary>
	/// 返回的地址
	/// </summary>
	[SugarColumn(ColumnDescription = "返回的地址", IsNullable = true, Length = 200)]
	public string? RedirectUri { get; set; }

	/// <summary>
	/// 自定微信授权值
	/// </summary>
	[SugarColumn(ColumnDescription = "自定微信授权值", IsNullable = true, Length = 50)]
	public string? State { get; set; }

	/// <summary>
	/// 微信授权地址
	/// </summary>
	[SugarColumn(ColumnDescription = "微信授权地址", IsNullable = true, Length = 200)]
	public string? WechatUri { get; set; }

	/// <summary>
	/// 微信授权完成后返回的地址
	/// </summary>
	[SugarColumn(ColumnDescription = "微信授权完成后返回的地址", IsNullable = true, Length = 200)]
	public string? GotoRedirectUri { get; set; }

	/// <summary>
	/// 浏览器
	/// </summary>
	[SugarColumn(ColumnDescription = "浏览器", IsNullable = true, Length = 200)]
	public string? Browser { get; set; }

	/// <summary>
	/// 操作系统
	/// </summary>
	[SugarColumn(ColumnDescription = "操作系统", IsNullable = true, Length = 100)]
	public string? OS { get; set; }

	/// <summary>
	/// IP地址
	/// </summary>
	[SugarColumn(ColumnDescription = "IP地址", IsNullable = true, Length = 20)]
	public string? IP { get; set; }

	/// <summary>
	/// 状态 1初始请求 2请求完成 3请求错误
	/// </summary>
	[SugarColumn(ColumnDescription = "状态 1初始请求 2请求完成 3请求错误")]
	public int Status { get; set; } = 1;

	/// <summary>
	/// 错误信息
	/// </summary>
	[SugarColumn(ColumnDescription = "错误信息", IsNullable = true, Length = 100)]
	public string? Error { get; set; }

	/// <summary>
	/// 创建日期
	/// </summary>
	[SplitField]
	[SugarColumn(ColumnDescription = "创建日期", IsNullable = true, IsOnlyIgnoreUpdate = true)]
	public DateTime CreateDate { get; set; } = DateTime.Now;

	/// <summary>
	/// 更新日期
	/// </summary>
	[SugarColumn(ColumnDescription = "更新日期", IsNullable = true, IsOnlyIgnoreInsert = true)]
	public DateTime? UpdateDate { get; set; }
}
